<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/sybida/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/sybida/bs/bootstrap.min.css">
    <script src="/sybida/common/js/locahostadress.js" charset="utf-8"></script>
    <style>
        html, body, div, ul, li, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ol, form, input, textarea, th, td, select {
            margin: 0;
            padding: 0;
        }
        #badge {
            width: 40px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            background-color: #FF9812;
            color: white;
            font-size: 12px;
            font-weight: 700;
            border-radius: 50%;

        }
        #advicetitlebig{
            border-top: none;
            border-bottom: 2px solid #25bb9b;
            width: 100%;
        }
        .advicetitleshow{
            height: 42px;
            line-height: 42px;
            font-size: 18px;
            font-weight: 500;
            text-align: center;
            background: #ffffff;
            color: black;
            width: 50%;
            float: left;
        }
        .advicetitleshow1{
            height: 42px;
            line-height: 42px;
            font-size: 18px;
            font-weight: 500;
            text-align: center;
            background: #ffffff;
            color: black;
            width: 50%;
            float: left;
        }

        .onadvicetitle{
            background: #25bb9b;
            color: #fff;
        }
        .infolist{
            width: 95%;
            margin:0 auto;
            border-bottom: 2px solid #ECECEC;
        }
        .infolisted{
            width: 95%;
            margin:0 auto;
            padding: 30px 15px 10px 15px;
            font-size: 16px;
            border-bottom: 2px solid #ECECEC;
        }
        .onlinght{
            transform: scale(1.01,1.01);
            box-shadow: 0 0 1px #0000ff;
            cursor: pointer;
        }
        .showmessage{
            display: block;
        }
        .hiddenmessage{
            display: none;
        }
        .infolisted .infolistedtop{
            height: 30px;
            line-height:30px;
            text-align: center;
            vertical-align: center;
            margin-bottom: 20px;
            font-size: 18px;
            font-weight: 500;
        }
        .infolisted .infolistedtop .infolistedtopleft{
            float: left;margin-left: 15px;
        }
        .infolisted .infolistedtop  .infolistedtopright{
            float: right;margin-right: 15px;
        }
    </style>
</head>
<body>
<div class="container" style="margin-top: 20px;">
    <div  style="border: 1px solid #ECECEC;width: 80%;margin: 0 auto;">

        <div id="advicetitlebig" >
            <a href="#">
                <div class="advicetitleshow onadvicetitle"  id="receiveinfo">
                    收件箱
                </div>
            </a>
            <a href="#" >
                <div class="advicetitleshow1" id="sendedinfo" >
                    已发送
                </div>
            </a>
            <div style="clear: both"></div>
        </div>
        <div id="receivemessage" class="showmessage" >
            <!--收件箱-->
        </div>
        <div id="sendmessage" class="hiddenmessage">
            <!--发件箱-->

        </div>
        <hr>
        <span id="nothingtodo"></span>
    </div>


</div>
</body>
<script src="/sybida/jquery/jquery-3.3.1.min.js"></script>
<script src="/sybida/layui/layui.js" charset="utf-8"></script>
<script src="/sybida/bs/bootstrap.min.js"></script>
<!--<script src="/sybida/publicTool/js/receiveNotice.js"></script>-->
<script>
    $(".advicetitleshow").mouseover(function () {
        var class1=$(this).attr("class")
        $(this).addClass("onlinght")
    })
    $(".advicetitleshow").mouseleave(function () {
        $(this).removeClass("onlinght")
    })
    $(".advicetitleshow1").mouseover(function () {
        var class1=$(this).attr("class")

        $(this).addClass("onlinght")
    })
    $(".advicetitleshow1").mouseleave(function () {

        $(this).removeClass("onlinght")
    })
    // <!--收件箱-->
    $(".advicetitleshow").click(function () {
        var class1=$(this).attr("class")
        if("advicetitleshow onlinght"==class1){
            $(this).toggleClass("onadvicetitle")
            $(".advicetitleshow1").removeClass("onadvicetitle")
            $("#receivemessage").removeClass("hiddenmessage")
            $("#receivemessage").toggleClass("showmessage")
            $("#sendmessage").removeClass("showmessage")
            $("#sendmessage").toggleClass("hiddenmessage")
            $("#nothingtodo").html("")
            $("#receivemessage").html("")
            toltalnumdef()
        }else{
            $("#nothingtodo").html("")
            $("#receivemessage").html("")
            toltalnumdef()
        }
    })
    // <!--发件箱-->
    $(".advicetitleshow1").click(function()  {
        var class1=$(this).attr("class")
        if("advicetitleshow1 onlinght"==class1){
            $(this).toggleClass("onadvicetitle")
            $(".advicetitleshow").removeClass("onadvicetitle")
            $("#sendmessage").removeClass("hiddenmessage")
            $("#sendmessage").toggleClass("showmessage")
            $("#receivemessage").removeClass("showmessage")
            $("#receivemessage").toggleClass("hiddenmessage")
            $("#nothingtodo").html("")
            $("#sendmessage").html("")
            toltalnum1();

        }else{
            $("#nothingtodo").html("")
            $("#sendmessage").html("")
            toltalnum1();
        }
    })

    var userid=getCookie("userid")
    var layer
    layui.use('layer', function(){
        layer = layui.layer;
    });
    var aflag=true//发件箱标志
    var bflag=true//收件箱标志
    <!-- page lazyloading -->
    $("#nothingtodo").html("")
    $("#receivemessage").html("")
    toltalnumdef()
    // <!--收件箱加载-->
    function toltalnumdef() {
        $.post({url:url+"news/receivemessagecount",
            data:"userid="+userid,
            beforeSend: function(request) {
                request.setRequestHeader("token", userid);
            },
            success:function (data1) {
                if(data1== -1000){
                    location.href=logindexurl
                }else{
                    var toltalnum=data1.code;

                    if(toltalnum==0){
                        $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
                没有信息  </div>`)
                    }else{
                        $("#receivemessage").html(`  `)
                        sendmessagea1(toltalnum);
                    }
                }
        }});
    }

    //全选全不选======================================================================================
    function showmseeage(){
        if($("#chk").get(0).checked){
            //循环下面所有checkbox
            $('input[name="optionAll"]').each(function(){
                //将checkbox状态改为选中
                $(this).prop("checked",true);
            });
        }else{

            $('input[name="optionAll"]').each(function(){
                $(this).prop("checked",false);
            });
        }
    }

    function sendmessage(){
        if($("#chk2").get(0).checked){
            //循环下面所有checkbox
            $('input[name="optionAll"]').each(function(){
                //将checkbox状态改为选中
                $(this).prop("checked",true);
            });
        }else{

            $('input[name="optionAll"]').each(function(){
                $(this).prop("checked",false);
            });
        }
    }
    // <!--收件箱加载-->
    function sendmessagea1(toltalnum) {
        var pagesize=7;
        var totalPages=Math.ceil(toltalnum/pagesize);
        var pagenum=totalPages;
        doSomethingsendmessagea1(pagenum--)
        if(pagenum > 0){
            doSomethingsendmessagea(pagenum)
        }

        $(window).scroll(function() {
            var scrollTop = $(document).scrollTop(),scrollHeight = $(document).height(),windowHeight = $(this).height();
            var positionValue = (scrollTop + windowHeight) - scrollHeight;
            if(aflag){
                if (pagenum>1) {
                    if (positionValue >= -2) {
                        if (pagenum > 1) {
                            layer.msg("玩命加载中")
                            pagenum--;
                            bflag=false;
                            bflag=doSomethingsendmessagea(pagenum);
                        }
                    }
                }
            }
        });
        function doSomethingsendmessagea(pagenum) {
            var userid1=getCookie("userid")
            $.post({url:url+"news/receivemessage",
                data:"pagesize="+pagesize+"&userid="+userid1+"&pagenum="+pagenum,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid1);
                },
                success:function (data) {
                if(data== -1000){
                    location.href=logindexurl
                }
                else {
                    var html = ``
                    for (var i = data.data.length - 1; i >= 0; i--) {
                        var mytime = data.data[i].newsSendTime
                        var isread = data.data[i].receiveIsRead
                        var mytime1 = mytime.substring(0, mytime.indexOf(".")).replace("T", "/")

                        if (isread == 0) {

                            html += ` <div class="infolisted">
            <div class="bg-primary infolistedtop">
                    <div class="infolistedtopleft" >
                        <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].receiveId}">
                        <a class="layui-btn layui-btn-danger layui-btn-xs" >删除</a>
                        </div>

                    <div class="infolistedtopright" ><span >

                    </span></div>
                    <div style="clear: both"></div>
            </div>
            <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
            </p>
            </div>
            <div style="margin-top: 10px;">
                <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                <div style="float: right;margin-right: 15px;"><span >
                 <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="receiveRead(${data.data[i].receiveId},this)" >标为已读</a>
                </span>
                 </div>
                <div style="clear: both"></div>

            </div>
        </div>`
                        } else {
                            html += ` <div class="infolisted">
            <div class="bg-primary infolistedtop">
                    <div class="infolistedtopleft" >
                        <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].receiveId}">
                        <a class="layui-btn layui-btn-danger layui-btn-xs">删除</a>
                        </div>
                    <div class="infolistedtopright" ><span >
                   </span></div>
                    <div style="clear: both"></div>
            </div>
            <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
            </p>
            </div>
            <div style="margin-top: 10px;">
                <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                <div style="float: right;margin-right: 15px;"><span >
                 已读
                 </span>
                 </div>
                <div style="clear: both"></div>

            </div>
        </div>`
                        }
                    }
                    $("#receivemessage").append(html)

                    bflag = true;
                    if (pagenum == 1) {
                        layer.msg("没有更多了---我是有底线的哦")
                        $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
        已经到底了！！</div>`)
                    }
//自己试试看=========================================================================
                    $("input[name='optionAll']").click(function () {
                        if ($(this).is(':checked')) {
                            // 如果当前框被选中，则判断是否需要勾选全选框
                            var checkbox = $("input[name='optionAll']");
                            var length = $(checkbox).length;
                            if (length > 0) {
                                for (var i = 0; i < length; i++) {
                                    if ($(checkbox[i]).is(":checked") != true) {
                                        break;// 如果有未勾选的选择框，不需要勾选全选，跳出循环
                                    }
                                    if (i == length - 1) {
                                        // 如果到最后一个选择框仍然是勾选状态，即所有选择框都被勾选，则勾选全选框
                                        $("#chk").prop("checked", true);
                                    }
                                }
                            }
                        } else {
                            // 如果当前选择框未勾选，则取消全选框勾选状态
                            $("#chk").prop("checked", false);
                        }
                    });

                }

            }});
        }
        function doSomethingsendmessagea1(pagenum) {
            var userid1=getCookie("userid")
            $.post({url:url+"news/receivemessage",
                data:"pagesize="+pagesize+"&userid="+userid1+"&pagenum="+pagenum,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid);
                },
                success:function (data) {
                if(data== -1000){
                    location.href=logindexurl
                }else{
                var html =`<div class="infolisted" >
                <div class="bg-primary infolistedtop" style="height:50px;">
                    <div class="infolistedtopleft" style="margin-top: 10px;">
                        <input style="height: 15px;width: 15px;" type="checkbox" id="chk" onclick="showmseeage()" >
                        <button id="deleteBySelect2" class="btn btn-danger" style="margin-bottom: 8px;height: 30px;">批量删除</button>
                        </div>
                    <div class="infolistedtopright" style="margin-top: 10px;" ><span >共${toltalnum}条</span></div>
                    <div style="clear: both"></div>
                </div>


            </div>`
                for(var i =data.data.length-1; i>=0; i--){
                    var mytime =data.data[i].newsSendTime
                    var isread=data.data[i].receiveIsRead
                    var mytime1 =mytime.substring(0,mytime.indexOf(".")).replace("T","/")
                    if(isread==0){

                        html+=` <div class="infolisted">
            <div class="bg-primary infolistedtop">
                    <div class="infolistedtopleft" >
                        <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].receiveId}">
                        <a class="layui-btn layui-btn-danger layui-btn-xs"  onclick="deleteReceiveMessage(${data.data[i].receiveId},this)" >删除</a>
                        </div>

                    <div class="infolistedtopright" ><span >

                    </span></div>
                    <div style="clear: both"></div>
            </div>
            <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
            </p>
            </div>
            <div style="margin-top: 10px;">
                <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                <div style="float: right;margin-right: 15px;"><span >
                 <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="receiveRead(${data.data[i].receiveId},this)" >标为已读</a>
                </span>
                 </div>
                <div style="clear: both"></div>

            </div>
        </div>`}else{
                        html+=` <div class="infolisted">
            <div class="bg-primary infolistedtop">
                    <div class="infolistedtopleft" >
                        <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].receiveId}">
                        <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="deleteReceiveMessage(${data.data[i].receiveId},this)">删除</a>
                        </div>
                    <div class="infolistedtopright" ><span >
                   </span></div>
                    <div style="clear: both"></div>
            </div>
            <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
            </p>
            </div>
            <div style="margin-top: 10px;">
                <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                <div style="float: right;margin-right: 15px;"><span >
                 已读
                 </span>
                 </div>
                <div style="clear: both"></div>

            </div>
        </div>`
                    }
                }
                $("#receivemessage").prepend(html)

                bflag=true;
                if(pagenum==1){
                    layer.msg("没有更多了---我是有底线的哦")
                    $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
        已经到底了！！</div>`)
                }
//自己试试看=========================================================================
                $("input[name='optionAll']").click(function (){
                    if ($(this).is(':checked')) {
                        // 如果当前框被选中，则判断是否需要勾选全选框
                        var checkbox = $("input[name='optionAll']");
                        var length = $(checkbox).length;
                        if (length > 0) {
                            for (var i = 0; i < length; i++) {
                                if ($(checkbox[i]).is(":checked") != true) {
                                    break;// 如果有未勾选的选择框，不需要勾选全选，跳出循环
                                }
                                if (i == length - 1) {
                                    // 如果到最后一个选择框仍然是勾选状态，即所有选择框都被勾选，则勾选全选框
                                    $("#chk").prop("checked", true);
                                }
                            }
                        }
                    } else {
                        // 如果当前选择框未勾选，则取消全选框勾选状态
                        $("#chk").prop("checked", false);
                    }
                });
               //批量删除收件箱
                $("#deleteBySelect2").click(function (){

                    var checkbox = $("input[name='optionAll']");
                    var s=new Array();
                    var j=0
                    for(var i = 0;i<checkbox.length;i++)
                    {
                        if(checkbox[i].checked==true)
                        {
                            s[j++]=(checkbox[i].value)
                        }
                    }
                    if(s.length>0){

                        var index=layer.confirm('确定删除吗？', {
                            btn: ['确定','取消'] //按钮
                        }, function(){
                            var userid1=getCookie("userid")
                            var messageInfo={
                                "list":s,
                                "userId":userid1,
                            }
                            $.post({
                                url:url+"/news/deleteallreceive",
                                contentType:"application/json",
                                data:JSON.stringify(messageInfo),
                                beforeSend: function(request) {
                                    request.setRequestHeader("token", userid1);
                                },
                                success:function(data) {
                                    if(data== -1000){
                                        location.href=logindexurl
                                    }else{
                                        if (data.code === 1) {
                                            layer.close(index)
                                            $("#nothingtodo").html("")
                                            $("#receivemessage").html("")
                                            toltalnumdef()
                                        } else {
                                            layer.close(index)
                                            layer.msg("删除失败请重试！");
                                        }
                                    }
                                }
                            })


                        }, function(){
                            layer.close(index)
                        });
                       }else{
                        layer.msg("所选数据为空！");

                    }
                })

            }}});
        }
    }
    // <!--发件箱加载-->
    function toltalnum1() {
        $.post({
            url:url+"news/hadSendmessagecount",
            data:"userid="+userid,
            beforeSend: function(request) {
                request.setRequestHeader("token", userid);
            },
            success:function (data1) {
                if(data1== -1000){
                    location.href=logindexurl
                }else {
                    var toltalnum = data1.code;
                    if (toltalnum == 0) {
                        $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
                你还没有发送任何信息 </div>`)
                    } else {

                        sendmessagea(toltalnum);
                    }
                }
        }});
    }
    // <!--发件箱加载-->
    function sendmessagea(toltalnum) {
        var pagesize=7;
        var totalPages=Math.ceil(toltalnum/pagesize);
        var pagenum=totalPages;
        doSomething1(pagenum--)
        if(pagenum > 0){
            doSomething(pagenum)
        }
        $(window).scroll(function() {
            var scrollTop = $(document).scrollTop(),scrollHeight = $(document).height(),windowHeight = $(this).height();
            var positionValue = (scrollTop + windowHeight) - scrollHeight;
            if(aflag){
                if (pagenum>1) {
                    if (positionValue >= -2) {
                        if (pagenum > 1) {
                            layer.msg("玩命加载中")
                            pagenum--;
                            aflag=false;
                            aflag=doSomething(pagenum);
                        }
                    }
                }
            }

        });
        function doSomething(pagenum) {
            var userid1=getCookie("userid")
            $.post({
                url:url+"news/hadsendmessage",
                data:"pagesize="+pagesize+"&userid="+userid1+"&pagenum="+pagenum,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid1);
                },
                success:function (data) {
                if(data== -1000){
                    location.href=logindexurl
                }else{
                var html =``
                for(var i =data.data.length-1; i>=0; i--){
                    var mytime =data.data[i].newsSendTime
                    var mytime1 =mytime.substring(0,mytime.indexOf(".")).replace("T","/")
                    html+=` <div class="infolisted">
                            <div class="bg-primary infolistedtop">
                             <div class="infolistedtopleft" >
                               <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].newsId}"></div>
                              <div class="infolistedtopright" ><span >${data.data[i].newsReadPeople}人已读</span></div>
                             <div style="clear: both"></div>
                                 </div>
                                 <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
                                                 </p>
                                             </div>
                                <div style="margin-top: 10px;">
                                    <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                                    <div style="float: right;margin-right: 15px;"><span ><a class="layui-btn layui-btn-danger layui-btn-xs"onclick="deletesendMessage(${data.data[i].newsId},this)">删除</a></span></div>
                                    <div style="clear: both"></div>

                                </div>
                            </div>`
                }
                $("#sendmessage").append(html)

                aflag=true;
                if(pagenum==1){
                    layer.msg("没有更多了---我是有底线的哦")
                    $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
        已经到底了！！</div>`)
                }


                $("input[name='optionAll']").click(function (){
                    if ($(this).is(':checked')) {
                        // 如果当前框被选中，则判断是否需要勾选全选框
                        var checkbox = $("input[name='optionAll']");
                        var length = $(checkbox).length;

                        if (length > 0) {
                            for (var i = 0; i < length; i++) {
                                if ($(checkbox[i]).is(":checked") != true) {
                                    break;// 如果有未勾选的选择框，不需要勾选全选，跳出循环
                                }
                                if (i == length - 1) {
                                    // 如果到最后一个选择框仍然是勾选状态，即所有选择框都被勾选，则勾选全选框
                                    $("#chk2").prop("checked", true);
                                }
                            }
                        }
                    } else {
                        // 如果当前选择框未勾选，则取消全选框勾选状态
                        $("#chk2").prop("checked", false);
                    }
                });

            }}});
    }
        function doSomething1(pagenum) {
            var userid1=getCookie("userid")
            $.post({
                url:url+"news/hadsendmessage",
                data:"pagesize="+pagesize+"&userid="+userid1+"&pagenum="+pagenum,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid);
                },
                success:function (data) {
                    if(data== -1000){
                        location.href=logindexurl
                    }else{
                var html =`<div class="infolisted" >
                <div class="bg-primary infolistedtop" style="height:50px;">
                    <div class="infolistedtopleft" style="margin-top: 10px;">
                        <input style="height: 15px;width: 15px;" type="checkbox" name=""  onclick="sendmessage()" id="chk2" value="">
                        <button id="deleteBySelect" class="btn btn-danger" style="margin-bottom: 8px;height: 30px;">批量删除</button>
                        </div>
                    <div class="infolistedtopright" style="margin-top: 10px;" ><span >共${toltalnum}条</span></div>
                    <div style="clear: both"></div>
                </div>
            </div>`
                for(var i =data.data.length-1; i>=0; i--){
                    var mytime =data.data[i].newsSendTime
                    var mytime1 =mytime.substring(0,mytime.indexOf(".")).replace("T","/")
                    html+=` <div class="infolisted">
            <div class="bg-primary infolistedtop">
                    <div class="infolistedtopleft" >
                        <input style="height: 15px;width: 15px;" type="checkbox" name="optionAll" value="${data.data[i].newsId}"></div>
                    <div class="infolistedtopright" ><span >${data.data[i].newsReadPeople}人已读</span></div>
                    <div style="clear: both"></div>
            </div>
            <div style="width: 98%;margin: 0 auto"><p >${data.data[i].newsTest}
            </p>
            </div>
            <div style="margin-top: 10px;">
                <div style="float: left"><span style="color: #aaa; font-weight: 400;"><i>${mytime1}</i></span></div>
                <div style="float: right;margin-right: 15px;"><span ><a class="layui-btn layui-btn-danger layui-btn-xs" onclick="deletesendMessage(${data.data[i].newsId},this)">删除</a></span></div>
                <div style="clear: both"></div>

            </div>
        </div>`
                }
                $("#sendmessage").prepend(html)

                aflag=true;
                if(pagenum==1){
                    layer.msg("没有更多了---我是有底线的哦")
                    $("#nothingtodo").html(`<div  style="text-align: center;padding-bottom: 20px;padding-top: 20px;font-size: 18px;color: white;background-color: #C1C1C1">
        已经到底了！！</div>`)
                }


                $("input[name='optionAll']").click(function (){
                    if ($(this).is(':checked')) {
                        // 如果当前框被选中，则判断是否需要勾选全选框
                        var checkbox = $("input[name='optionAll']");
                        var length = $(checkbox).length;

                        if (length > 0) {
                            for (var i = 0; i < length; i++) {
                                if ($(checkbox[i]).is(":checked") != true) {
                                    break;// 如果有未勾选的选择框，不需要勾选全选，跳出循环
                                }
                                if (i == length - 1) {
                                    // 如果到最后一个选择框仍然是勾选状态，即所有选择框都被勾选，则勾选全选框
                                    $("#chk2").prop("checked", true);
                                }
                            }
                        }
                    } else {
                        // 如果当前选择框未勾选，则取消全选框勾选状态
                        $("#chk2").prop("checked", false);
                    }
                });
                //批量删除发件箱
                $("#deleteBySelect").click(function (){

                    var checkbox = $("input[name='optionAll']");
                    var s=new Array();
                    var j=0
                    for(var i = 0;i<checkbox.length;i++)
                    {
                        if(checkbox[i].checked==true)
                        {
                            s[j++]=(checkbox[i].value)
                        }
                    }
                    if(s.length>0){
                        var index=layer.confirm('确定删除吗？', {
                            btn: ['确定','取消'] //按钮
                        }, function(){
                            $.post({
                                url:url+"/news/deleteallnews",
                                contentType:"application/json",
                                data:JSON.stringify(s),
                                beforeSend: function(request) {
                                    request.setRequestHeader("token", userid);
                                },
                                success:function(data){
                                    if(data== -1000){
                                        location.href=logindexurl
                                    }else {
                                        if (data.code === 1) {
                                            layer.close(index)
                                            $("#nothingtodo").html("")
                                            $("#sendmessage").html("")
                                            toltalnum1();
                                        } else {
                                            layer.close(index)
                                            layer.msg("删除失败请重试！");
                                        }
                                    }
                                }
                            })
                        }, function(){
                            layer.close(index)
                        });
                    }else{
                        layer.alert("所选数据为空！");
                    }
                })
            }}});
        }
    }


    //单个删除发件箱

    //单个删除发件箱
    function deletesendMessage(id,elaa){
       var index=layer.confirm('确定删除这条已经发送成功的信息吗？', {
           btn: ['确定','取消'] //按钮
       }, function(){
           $(elaa).parent().parent().parent().parent().remove()
           $.post({url:url+"/news/delectonesend",
               data:"newsId="+id,
               beforeSend: function(request) {
                   request.setRequestHeader("token", userid);
               },
               success:function (data) {
           }})
           layer.close(index)
       }, function(){
           layer.close(index)
       });
    }
    //单个删除收件箱
    function deleteReceiveMessage(id,elaa) {
        var userid1=getCookie("userid")
        var index=layer.confirm('确定删除这条接收到的信息吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $(elaa).parent().parent().parent().remove()
            $.post({url:url+"/news/delectonereceive",
                data:"receiveId="+id+"&userid="+userid1,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid1);
                },
                success:function (data) {
            }})
            layer.close(index)
        }, function(){
            layer.close(index)
        });
    }
    // <!--标为已读===========================-->
    function receiveRead(id,elaa) {
        var userid1=getCookie("userid")
        $.ajax({
            url: url+"/news/isread",
            type: "post",
            data: "receiveId="+id+"&userid="+userid1 ,
            dataType: "json",
            beforeSend: function(request) {
                request.setRequestHeader("token", userid1);
            },
            success: function (data) {
                if(data== -1000){
                    location.href=logindexurl
                }else{
                if (data.code == 1) {
                    elaa.parentNode.parentNode.innerHTML="已读"
                } else {
                    alert("标记失败！")
                }
            }}
        })
    }




</script>
</html>